import type { AddressItem, AddressParams } from "@/types/address"
import { http } from "@/utils/http"


/**
 * 添加收货地址
 * @param data
 * @returns
 */
export const postMemberAddressAPI = (data: AddressParams) => {
  return http({
    method: 'POST',
    url: "/member/address",
    data,
  })
}

/**
 * 获取收货地址列表
 * @returns
 */
export const getMemberAddressListAPI = () => {
  return http<AddressItem[]>({
    method: 'GET',
    url: '/member/address',
  })
}


/**
 * 获取收货地址详情
 * @param id 地址ID
 * @returns
 */
export const getMemberAddressByIdsAPI = (id: string) => {
  return http<AddressItem>({
    method: 'GET',
    url: `/member/address/${id}`,
  })
}

/**
 * 修改收货地址
 * @param id  地址id
 * @param data 表单数据
 * @returns
 */

export const putMemberAddressByIdAPI = (id: string, data: AddressParams) => {

  return http<AddressItem>({
    method: 'PUT',
    url: `/member/address/${id}`,
    data,
  })
}

/**
 * 删除地址
 * @param id
 * @returns
 */

export const deleteMemberAddressByIdAPI = (id: string) => {

  return http({
    method: 'DELETE',
    url: `/member/address/${id}`,

  })
}
